//
//  FFRecvPayPayVC.m
//  LLWallet
//
//  Created by tt on 2020/12/23.
//

#import "FFRecvPayPayVC.h"

@interface FFRecvPayPayVC ()

@property(nonatomic,strong) UIView *bigFooterView;

@property(nonatomic,strong) UIButton *payBtn;

@end

@implementation FFRecvPayPayVC

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.viewModel = [FFRecvPayPayVM new];
    }
    return self;
}

- (void)viewDidLoad {
    
    self.viewModel.uid = self.uid;
    self.viewModel.vercode = self.vercode;
    self.viewModel.amount = self.amount;
    self.viewModel.remark = self.remark;

    
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    
    self.bigFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WKScreenWidth, 1000)];
    self.bigFooterView.backgroundColor = [WKApp shared].config.cellBackgroundColor;
    self.bigFooterView.opaque = YES;
    [self.tableView.tableFooterView addSubview:self.bigFooterView];
    
    if(self.amount>0) {
        [self.view addSubview:self.payBtn];
    }
    
}

- (void)viewConfigChange:(WKViewConfigChangeType)type {
    [super viewConfigChange:type];
    if(type == WKViewConfigChangeTypeStyle) {
        self.bigFooterView.backgroundColor  = [WKApp shared].config.cellBackgroundColor;
    }
}

- (UIButton *)payBtn {
    if(!_payBtn) {
        CGFloat bottom = 0.0f;
        if (@available(iOS 11.0, *)) {
            bottom = [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom;
        }
        _payBtn = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 50.0f)];
        _payBtn.lim_left = self.view.lim_width - _payBtn.lim_width - 15.0f;
        _payBtn.lim_top = self.view.lim_height - bottom - _payBtn.lim_height - 100.0f;
        [_payBtn setTitle:LLang(@"付款") forState:UIControlStateNormal];
        [_payBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _payBtn.backgroundColor = [WKApp shared].config.themeColor;
        _payBtn.layer.masksToBounds  =YES;
        _payBtn.layer.cornerRadius = 4.0f;
        
        [_payBtn addTarget:self action:@selector(payPressed) forControlEvents:UIControlEventTouchUpInside];
    }
    return _payBtn;
}

-(void) payPressed {
    [self.viewModel toPay];
}

@end
